{% extends "layout/basic.html" %}
{% import "components/paginator.html" as paginator with context %}
{% import "components/nothing.html" as nothing with context %}
{% block content %}
<div class="row">
  <div class="medium-12 columns">
    <div class="section visible ranking_sm">
        <h2>排名规则</h2>
        <h3>排名规则更改</h3>
        <p>暂时取消比赛成绩参与排名，现在排名以题目的得分作为排名依据，题目得分100，rp增加1</p>
        <p>排名更新时间为每天夜间自动更新</p>
    </div>
    <div class="section" style="padding-top: 0.8rem;">
      <div class="section__body no-padding">
        <div data-fragment-id="ranking">
          {% if not udocs.length %}
          <blockquote class="note">{{ _('The ranking page is not updated realtime.') }}</blockquote>
          {{ nothing.render('Sorry, there are no users in this domain.') }}
          {% else %}
          <table class="data-table">
            <colgroup>
              <col class="col--rank">
              <col class="col--user">
              <col class="col--rp">
              {% for key, def in model.rp %}
                {% if not def.hidden %}
                  <col class="col--detail rp-{{ key }}">
                {% endif %}
              {% endfor %}
              <col class="col--ac">
              <col class="col--bio">
            </colgroup>
            <thead>
              <tr>
                <th class="col--rank">{{ _('Rank') }}</th>
                <th class="col--user">{{ _('Username') }}</th>
                <th class="col--rp">{{ _('RP') }}</th>
                {% for key, def in model.rp %}
                  {% if not def.hidden %}
                    <th class="col--detail rp-{{ key }}">{{ _('rpDetailText_' + key) }}</th>
                  {% endif %}
                {% endfor %}
                <th class="col--ac">{{ _('Accept') }}</th>
                <th class="col--bio">{{ _('Bio') }}</th>
              </tr>
            </thead>
            <tbody>
              {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
              <tr>
                <td class="col--rank">{{ handler.user.rank|default('-') }}</td>
                <td class="col--user">{{ user.render_inline(handler.user) }}</td>
                <td class="col--rp">{{ handler.user.rp|default(0)|round(0) }}</td>
                {% for key, def in model.rp %}
                  {% if not def.hidden %}
                    <td class="col--detail rp-{{ key }}">{{ handler.user.rpInfo[key]|round if (handler.user.rpInfo|default({}))[key] else '-' }}</td>
                  {% endif %}
                {% endfor %}
                <td class="col--ac">{{ handler.user.nAccept|default(0) }}</td>
                <td class="col--bio">{{ handler.user.bio|default('')|truncate(64, true)|markdownInline|safe }}</td>
              </tr>
              {% endif %}
              {%- for udoc in udocs -%}
              <tr>
                <td class="col--rank">{{ (page - 1) * 100 + loop.index }}</td>
                <td class="col--user">{{ user.render_inline(udoc) }}</td>
                <td class="col--rp">{{ udoc.rp|default(0)|round(0) }}</td>
                {% for key, def in model.rp %}
                  {% if not def.hidden %}
                    <td class="col--detail rp-{{ key }}">{{ udoc.rpInfo[key]|round if udoc.rpInfo[key] else '-' }}</td>
                  {% endif %}
                {% endfor %}
                <td class="col--ac">{{ udoc.nAccept|default(0) }}</td>
                <td class="col--bio">{{ udoc.bio|default('')|truncate(64, true)|markdownInline|safe }}</td>
              </tr>
              {%- endfor -%}
            </tbody>
          </table>
          {{ paginator.render(page, upcount) }}
          {% endif %}
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}